package com.hspedu.homework;

import java.util.TreeSet;

/**
 * @Author Stringzhua
 * @Date 2024/3/13 19:58
 * description:
 */
@SuppressWarnings("all")
public class homework05 {
    public static void main(String[] args) {
        TreeSet treeSet = new TreeSet();
        //add方法:因为TreeSet()构造器没有传入Comparator接口的匿名内部类
        //所以在底层Comparable<? super K> K=(Comparable<? super K>) key;
        //即 把Person转成Comparable类型
        treeSet.add(new Personal());//ClassCastException
        System.out.println("treeSet = " + treeSet);
    }
}

class Personal implements Comparable{
    @Override
    public int compareTo(Object o) {
        return 0;
    }
}